﻿using System;
using System.Data;
using MyDMS.DAL;
using System.Linq;

public partial class admin_Default : PageBaseClass
{
    private MyDMSEntity _myDmsEntity = new MyDMSEntity();
    protected void Page_Load(object sender, EventArgs e)
    {
        Office o = _myDmsEntity.Office.FirstOrDefault(r => r.Office_Code==Author.office_Code);
        lblOfficeName.Text = o.Office_Name;
        lblOfficeEmail.Text = o.Account_Email;

        //object dataObject;
        //new SqlFactory().ExecuteQuery("select count(*) from UserInfo ui " +
        //" inner join JobDescription jd on ui.JD_Code=jd.JD_Code" +
        //" where jd.Office_Code = " + _author.office_Code, out dataObject, SqlFactory.DataObjectType.DataSet);

        //if (dataObject != null)
        //{
        //lblTotUsers.Text = (from ui in _myDmsEntity.User
        //                       join jd in _myDmsEntity.JobDescription on ui.JD_Code equals jd.JD_Code
        //                       where jd.Office_Code == _author.office_Code
        //                       select ui).Count().ToString();
        //}
        lblTotUsers.Text = _myDmsEntity.User.Count().ToString();

        //dataObject = null;
        //new SqlFactory().ExecuteQuery("select count(*) from Project p " +
        //" where p.Office_Code = " + _author.office_Code, out dataObject, SqlFactory.DataObjectType.DataSet);

        //if (dataObject != null)
        //{
        lblTotProjects.Text = _myDmsEntity.Project.Count().ToString();
        //}

        //dataObject = null;
        //new SqlFactory().ExecuteQuery("select count(*) from Document ud " +
        //" where ud.Office_Code = " + _author.office_Code, out dataObject, SqlFactory.DataObjectType.DataSet);

        //if (dataObject != null)
        //{
        lblTotDocuments.Text = _myDmsEntity.UserDocument.Count().ToString();
        //}
    }
}
